#!D:/CODE/python
# -*- coding: utf-8 -*-
# @Time : 2020/5/25 15:36
# @Author : Alexdong
# @Site : 
# @File : 生成器.py
# @Software: PyCharm
# Functional description:

def create_num(all_num):
    a, b = 0, 1
    current_num = 0
    while current_num < all_num:
        yield a
        a, b = b, a+b
        current_num += 1
    return "ok"

obj = create_num(10)
while True:
    try:
        ret = next(obj)
        print(ret)
    except Exception as ret:
        print(ret.value)
        break